package com.example.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by wushuai on 17/8/30.
 */
@Controller
@RequestMapping("/home")
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    @RequestMapping("/index")
    public String index () {
        logger.info("index");

        return "index";
    }

    @RequestMapping("/a")
    public ModelAndView a (@RequestParam("name") String name) {
        logger.info("a");

        ModelMap params = new ModelMap();
        params.addAttribute("name", name);
        ModelAndView modelAndView = new ModelAndView("a");
        modelAndView.addObject("params", params);
        modelAndView.addObject("message", "message");

        return modelAndView;
    }

}
